<?php

require_once '../db/get/post.php';

define('DEFAULT_POST_PAGE_SIZE', 15);
define('DEFAULT_POST_PAGE_START', 1);

function showPage($_PAGE,$_TPL) {

  if( $_REQUEST['tid'] < 0 ) {
    die( "BREAKAGE" ); // BREAKAGE
  }
  $tid = (int)$_REQUEST['tid'];
  $page = (isset($_REQUEST['page'])) ? (int)$_REQUEST['page'] : DEFAULT_POST_PAGE_START;
  $psize = ((int)$_REQUEST['psize'] > 0) ? (int)$_REQUEST['psize'] : DEFAULT_POST_PAGE_SIZE;
  $posts = getFlatPosts( $tid, ($page-1)*$psize, $psize );
  $count = postCount( $tid );

  for( $i = count($posts)-1; $i > -1; --$i ){ 
    // we need to desmurf all the smurfs, but where? Not in template
 //   $posts[$i]['datum'] = smurf($posts[$i]['datum'], $posts[$i]['smurfKey']);
  }


  $_TPL['tid'] = $tid;
  $_TPL['fid'] = $posts[0]['fid'];
  $_TPL['ttitle'] = $posts[0]['ttitle'];
  $_TPL['ftitle'] = $posts[0]['ftitle'];
  $_TPL['stream'] = $posts[0]['stream'];
  $_TPL['posts'] = $posts;
  $_TPL['count'] = $count;
  $_TPL['page'] = $page;
  $_TPL['psize'] = $psize;

  $_PAGE = 'Post';

  //skin_ShowPosts( $tnum, $posts, $count, $start, $inc );

  $posts = NULL;
}

?>
